from django.contrib.syndication.feeds import Feed
from models import *

class LatestArchives(Feed):
    title = Blog.get_or_insert(key_name='blog').name
    link = "/"
    description = Blog.get_or_insert(key_name='blog').description

    def item_pubdate(self,item):
        return item.pub_date

    def item_categories(self,item):
        return [item.category.name]

    item_author_name = Author.get_or_insert(key_name='author').name

    def items(self):
        return Archive.all().order('-pub_date')[:20]
